package seqlist.leetcode;

//删除排序链表的重复元素，重复元素保留1次
public class Num83_deleteDuplicates {
    public ListNode deleteDuplicates(ListNode head) {
        ListNode dummyHead=new ListNode(101);
        dummyHead.next=head;
        ListNode prev=dummyHead;
        ListNode cur=prev.next;
        while (cur!=null){
            if(prev.val==cur.val){
                prev.next=cur.next;
            }else {
                prev=prev.next;
            }
            cur=cur.next;
        }
        return dummyHead.next;
    }
}
